package top.kaoshanji.p2ch06a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Objects;

/**
 * 代码清单 p2ch06a-12：Objects类的hash和hashCode方法的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/17 19:12
 */
public class ObjectsExample03 {

    private static final Logger logger = LogManager.getLogger(ObjectsExample03.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p2ch06a-12：Objects类的hash和hashCode方法的使用示例...");

        int hashCode1 = Objects.hashCode("Hello");
        int hashCode2 = Objects.hash("Hello", "World"); // int 值溢出了...
        int hashCode3 = Objects.hash("Hello");

        logger.info("...hashCode1:{}...", hashCode1);
        logger.info("...hashCode2:{}...", hashCode2);
        logger.info("...hashCode3:{}...", hashCode3);

    }

}
